home *** CD-ROM | disk | FTP | other *** search
/ Apple II Magazines (DO) / Nibble Volume 09, No. 10 (1988-10)(MicroSPARC)(Side B).zip / Nibble Volume 09, No. 10 (1988-10)(MicroSPARC)(Side B).do / HELPER.S < prev    next >
Text File  |  1996-12-24  |  29KB  |  494 lines

  1. *
  2. *  HELPER Source Code
  3. *  By Kenn Scribner
  4. *  Copyright (C) 1988
  5. *  MicroSparc Inc.
  6. *  Concord,  MA  01742
  7. *
  8. *  ORCA/M 4.1 Assembler
  9. *
  10.                   ORG    $7000                   ;assemble at $7000 (28672 decimal)
  11.                   65816  ON                      ;enable 65816 opcodes
  12.                   LONGA  OFF                     ;use 8 bit accumulator
  13.                   LONGI  OFF                     ;use 8 bit X and Y registers
  14.  
  15. HELPER      START
  16. *
  17. * Local EQUates
  18. *
  19. A1L            EQU   $3C                      ;generic temprorary registers for MOVE
  20. A2L            EQU   $3E
  21. A4L            EQU   $42
  22. LINNUM      EQU   $50                      ;general purpose 16 bit register
  23. VARPNT      EQU   $83                      ;last used variable pointer
  24. FACLO        EQU   $A1                      ;temporary holding register
  25. CHRGET      EQU   $B1                      ;advance TXTPTR to next token/character
  26. AMPVECT    EQU   $3F5                     ;ampersand routine vector (pointer)
  27. ERROR        EQU   $D412                    ;ASoft error handler
  28. CHKCOM      EQU   $DEBE                    ;check for comma in program, err if not
  29. PTRGET      EQU   $DFE3                    ;locate/create variable at TXTPTR
  30. GIVAYF      EQU   $E2F2                    ;float A,Y into FAC for storage
  31. GETBYTC    EQU   $E6F5                    ;evaluate formula, return integer value
  32. MOVMF        EQU   $EB2B                    ;store packed FAC, pointed to by Y,X
  33. SETHMEM1  EQU   $F28E                    ;calculate and set HIMEM
  34. MOVE          EQU   $FE2C                    ;Monitor memory move routine
  35. IORTS        EQU   $FF58                    ;Default DOS 3.3 & return address
  36. TBCOLOR    EQU   $E0C022                  ;Text/Background color register
  37. KYMODREG  EQU   $E0C025                  ;special key register
  38. LANGSEL    EQU   $E0C02B                  ;language select (display) register
  39. CLOCKCTL  EQU   $E0C034                  ;border color register
  40. CYAREG      EQU   $E0C036                  ;system speed register
  41.  
  42.                          ;...............................................................
  43.                          ;
  44.                          ; ProDOS EQUates
  45.                          ;...............................................................
  46.  
  47. GETBUFR    EQU   $BEF5                    ;reserve A pages (256 bytes) above HIMEM
  48. KVERSION  EQU   $BFFF                    ;ProDOS ID byte (+ ProDOS, - DOS 3.3)
  49.  
  50.                          ;...............................................................
  51.                          ;
  52.                          ; DOS 3.3 EQUates
  53.                          ;...............................................................
  54.  
  55. MAXFILES  EQU   $A258                    ;DOS 3.3 MAXFILES subroutine
  56.  
  57. *
  58. * Beginning of Program Text.
  59. *
  60.                   CLC                            ;begin by storing original values
  61.                   XCE                            ;enter native mode
  62.                   LDA   >CYAREG                  ;find the current speed
  63.                   AND   #$10000000               ;mask out all but speed bit
  64.                   STA   SPDMSK+1                 ;store for restore
  65.                   LDA   >LANGSEL                 ;find current displayed language
  66.                   AND   #%11101000               ;mask out all but language/primary bits
  67.                   STA   LANGMSK+1                ;store for restore
  68.                   LDA   >TBCOLOR                 ;find current text/background colors
  69.                   STA   TBMSK+1                  ;store for restore
  70.                   LDA   >CLOCKCTL                ;find border color
  71.                   AND   #%00001111               ;mask out all but border color bits
  72.                   STA   BGMSK+1                  ;store for restore
  73.                   SEC                            ;return to emulation mode
  74.                   XCE
  75.                   LDA   KVERSION                 ;check for ProDOS
  76.                   BPL   PRODOS                   ;positive value means ProDOS loaded
  77. DOS33        LDA   #$01                     ;DOS 3.3 loaded, set MAXFILES = 1
  78.                   JSR   MAXFILES
  79.                   STZ   LINNUM                   ;set HIMEM = $9600
  80.                   LDA   #$96
  81.                   STA   LINNUM+1
  82.                   JSR   SETHMEM1
  83.                   BNE   GOTMEM                   ;move program (branch always taken)
  84. PRODOS      LDA   #$03                     ;reserve 3 pages (3 X 256 bytes)
  85.                   JSR   GETBUFR                  ;request memory from BASIC.SYSTEM
  86.                   BCC   GOTMEM                   ;memory available, no errors
  87. MEMERR      LDX   #$4D                     ;?OUT OF MEMORY error
  88.                   JMP   ERROR
  89. GOTMEM      PHA                            ;save returned page number on stack...
  90.                   PHA                            ;...for later use
  91.                   LDA   #<BEGIN                  ;move program...
  92.                   STA   A1L
  93.                   LDA   #>BEGIN
  94.                   STA   A1L+1
  95.                   LDA   #<END
  96.                   STA   A2L
  97.                   LDA   #>END
  98.                   STA   A2L+1
  99.                   STZ   A4L
  100.                   PLA
  101.                   STA   A4L+1
  102.                   LDY   #$00
  103.                   JSR   MOVE                     ;...move completed
  104.                   LDA   #$4C                     ;"JMP" opcode (making sure it's there)
  105.                   STA   AMPVECT
  106.                   LDA   AMPVECT+1                ;save old vector (in case you're...
  107.                   STA   EXTAMPR+1                ; ...using another & utility)
  108.                   LDA   AMPVECT+2
  109.                   STA   EXTAMPR+2
  110.                   LDA   #$00                     ;install new vector
  111.                   STA   AMPVECT+1
  112.                   PLA
  113.                   STA   AMPVECT+2
  114.                   RTS                            ;installed!
  115.  
  116.                          ;...............................................................
  117.                          ;
  118.                          ; Beginning of real & program (to be moved into operating location).
  119.                          ;...............................................................
  120.  
  121. BEGIN        CMP   #$5F                     ;'_' delimiter
  122.                   BEQ   PARSE                    ;'_' found (must be HELPER routine?)
  123. EXTAMPR    JMP   IORTS                    ;not HELPER routine, try another & pgm.
  124. PARSE        CLC                            ;enter native mode
  125.                   XCE
  126.                   SEP   #$20                     ;set up 8 bit registers
  127.                   SEC                            ;return to emulation mode
  128.                   XCE
  129.                   JSR   CHRGET                   ;read next token
  130.  
  131.                          ;...............................................................
  132.                          ;
  133.                          ; LOAD Subroutine (sets new display language).
  134.                          ;...............................................................
  135. LDCHK        CMP   #$B6                     ;"LOAD" token value
  136.                   BNE   RECHK                    ;no, check for RESTORE token
  137. LOAD          JSR   CHRGET                   ;get another token
  138.                   CMP   #$D0                     ;"=" token value
  139.                   BEQ   L1                       ;found it, continue
  140.                   LDX   #$10                     ;not there, generate syntax error
  141.                   JMP   ERROR
  142. L1              JSR   GETBYTC                  ;return integer language value in X
  143.                   TXA
  144.                   CMP   #$08                     ;language greater than 8?
  145.                   BCC   LVALID                   ;no, valid language number
  146.                   LDX   #$35                     ;yes, generate illegal quantity error
  147.                   JMP   ERROR
  148. LVALID      ASL   A                        ;move language to upper three bits
  149.                   ASL   A                        ; (xxxxxYYY to YYYxxxxx, Y = language)
  150.                   ASL   A
  151.                   ASL   A
  152.                   ASL   A
  153.                   ORA   #%00001000               ;set bit for primary language (YYYxPxxx)
  154.                   STA   FACLO                    ;save for later masking
  155.                   CLC                            ;enter native mode
  156.                   XCE
  157.                   LDA   >LANGSEL                 ;load in current language register
  158.                   AND   #%00010000               ;clear all mode bits but NTSC/PAL video
  159.                   ORA   FACLO                    ;set new language
  160.                   STA   >LANGSEL                 ;store new language
  161.                   SEC                            ;return to emulation mode
  162.                   XCE
  163.                   RTS                            ;done!
  164.  
  165.                          ;...............................................................
  166.                          ;
  167.                          ; RESTORE Subroutine.  Values shown are default values (according to
  168.                          ;  the Control Panel).  These will be modified to reflect what's
  169.                          ;  being used by the system at the moment HELPER is first executed.
  170.                          ;...............................................................
  171. RECHK        CMP   #$AE                     ;"RESTORE" token value
  172.                   BNE   SPCHK                    ;no, check for SPEED= token
  173. RESTORE    JSR   CHRGET                   ;yes, point TXTPTR to formula/variable
  174.                   CLC                            ;enter native mode
  175.                   XCE
  176.                   LDA   >CYAREG                  ;find current speed
  177.                   AND   #%01111111               ;set to slow (speed bit = 0)
  178. SPDMSK      ORA   #%10000000               ;speed mask (self-modified before MOVE)
  179.                   STA   >CYAREG                  ;restore system speed
  180.                   LDA   >LANGSEL                 ;find current language
  181.                   AND   #%00010000               ;mask out language (leave video bit)
  182. LANGMSK    ORA   #%00011000               ;language mask (self-mod'd before MOVE)
  183.                   STA   >LANGSEL                 ;restore display language
  184. TBMSK        LDA   #%11110110               ;T/B mask (self-modified before MOVE)
  185.                   STA   >TBCOLOR                 ;restore Text/Background colors
  186.                   LDA   >CLOCKCTL                ;find current border color
  187.                   AND   #%11110000               ;clear border color bits
  188. BGMSK        ORA   #%00000110               ;border color mask (self-mod'd)
  189.                   STA   >CLOCKCTL                ;restore border color
  190.                   SEC                            ;return to emulation mode
  191.                   XCE
  192.                   RTS                            ;done!
  193.  
  194.                          ;...............................................................
  195.                          ;
  196.                          ; SPEED= Subroutine (sets system speed).
  197.                          ;...............................................................
  198. SPCHK        CMP   #$A9                     ;"SPEED=" token
  199.                   BNE   CLCHK
  200. SPEED        JSR   GETBYTC
  201.                   LDA   FACLO                    ;retrieve current speed
  202.                   BEQ   SETSPD                   ;zero, SLOW speed
  203.                   LDA   #$80                     ;non-zero, set FAST speed
  204.                   STA   FACLO                    ;save for later masking
  205. SETSPD      CLC                            ;enter native mode
  206.                   XCE
  207.                   LDA   >CYAREG                  ;find current speed
  208.                   AND   #%01111111               ;zero bit for masking
  209.                   ORA   FACLO                    ;mask bit (sets to "1" if FAST selected)
  210.                   STA   >CYAREG                  ;save new system speed
  211.                   SEC                            ;return to emulation mode
  212.                   XCE
  213.                   RTS                            ;done!
  214.  
  215.                          ;...............................................................
  216.                          ;
  217.                          ; COLOR= Subroutine (sets background color).
  218.                          ;...............................................................
  219. CLCHK        CMP   #$A0                     ;"COLOR=" token value
  220.                   BNE   HCCHK
  221. COLOR        JSR   GETBYTC
  222.                   TXA
  223.                   CMP   #$10                     ;color greater than 15 selected?
  224.                   BCC   CVALID                   ;no, valid color
  225.                   LDX   #$35                     ;yes, illegal quantity error
  226.                   JMP   ERROR
  227. CVALID      STA   FACLO                    ;save color for masking
  228.                   CLC                            ;enter native mode
  229.                   XCE
  230.                   LDA   >TBCOLOR                 ;find current background color
  231.                   AND   #%11110000               ;clear color bits for masking
  232.                   ORA   FACLO                    ;set color bits
  233.                   STA   >TBCOLOR                 ;save new background color
  234.                   SEC                            ;return to emulation mode
  235.                   XCE
  236.                   RTS                            ;done!
  237.  
  238.                          ;...............................................................
  239.                          ;
  240.                          ; HCOLOR= Subroutine (Sets border color).
  241.                          ;...............................................................
  242. HCCHK        CMP   #$92                     ;"HCOLOR=" token value
  243.                   BNE   TECHK
  244. HCOLOR      JSR   GETBYTC
  245.                   TXA
  246.                   CMP   #$10                     ;color greater than 15 selected?
  247.                   BCC   HVALID                   ;no, valid color
  248.                   LDX   #$35                     ;yes, generate illegal quantity error
  249.                   JMP   ERROR
  250. HVALID      STA   FACLO                    ;save color for masking
  251.                   CLC                            ;enter native mode
  252.                   XCE
  253.                   LDA   >CLOCKCTL                ;find current border color
  254.                   AND   #%11110000               ;clear color bits for masking
  255.                   ORA   FACLO                    ;set color bits
  256.                   STA   >CLOCKCTL                ;save new border color
  257.                   SEC                            ;return to emulation mode
  258.                   XCE
  259.                   RTS                            ;done!
  260.                          ;...............................................................
  261.                          ;
  262.                          ; TEXT Subroutine (Sets text color).
  263.                          ;...............................................................
  264. TECHK        CMP   #$89                     ;"TEXT" token value
  265.                   BNE   RDCHK
  266. TEXT          JSR   CHRGET                   ;advance TXTPTR to next token
  267.                   CMP   #$D0                     ;"=" token value
  268.                   BEQ   T1                       ;found it, continue
  269.                   LDX   #$10                     ;not there, generate syntax error
  270.                   JMP   ERROR
  271. T1              JSR   GETBYTC                  ;return integer text color in X
  272.                   TXA
  273.                   CMP   #$10                     ;is it greater than 15?
  274.                   BCC   TVALID                   ;no, continue
  275.                   LDX   #$35                     ;yes, generate illegal quantity error
  276.                   JMP   ERROR
  277. TVALID      ASL   A                        ;move 4 bits to high nibble
  278.                   ASL   A                        ; (xxxxYYYY to YYYYxxxx, Y = color bits)
  279.                   ASL   A
  280.                   ASL   A
  281.                   STA   FACLO                    ;save for later masking
  282.                   CLC                            ;enter native mode
  283.                   XCE
  284.                   LDA   >TBCOLOR                 ;find current text color
  285.                   AND   #%00001111               ;clear text color bits for masking
  286.                   ORA   FACLO                    ;set text color bits
  287.                   STA   >TBCOLOR                 ;save new text color
  288.                   SEC                            ;return to emulation mode
  289.                   XCE
  290.                   RTS                            ;done!
  291.  
  292.                          ;...............................................................
  293.                          ;
  294.                          ; READ Subroutine (Reads current system values).
  295.                          ;...............................................................
  296. RDCHK        CMP   #$87                     ;"READ" token value
  297.                   BEQ   READ
  298. SYNERR      LDX   #$10                     ;illegal token, generate syntax error
  299.                   JMP   ERROR
  300. READ          JSR   CHRGET                   ;advance TXTPTR to next token
  301.                   CMP   #$D0                     ;"=" token value
  302.                   BNE   SYNERR
  303.                   JSR   CHRGET                   ;advance TXTPTR to string variable
  304.                   JSR   PTRGET                   ;find string text pointer
  305.                   LDY   #$01                     ;retrieve pointer low byte
  306.                   LDA   (VARPNT),Y
  307.                   TAX                            ;save low byte
  308.                   INY                            ;retrieve pointer high byte
  309.                   LDA   (VARPNT),Y
  310.                   STX   VARPNT                   ;reset VARPNT to point to text data
  311.                   STA   VARPNT+1
  312.                   LDY   #$00                     ;read first character of string's text
  313.                   LDA   (VARPNT),Y
  314.                   AND   #%11011111               ;turn character into upper-case letter
  315. RDCOLR      CMP   #'B'                     ;want background color?
  316.                   BNE   RDCAPS                   ;no, check for Caps Lock status
  317.                   JSR   CHKCOM                   ;yes, now look for comma separator
  318.                   JSR   PTRGET                   ;find/create return status variable
  319.                   CLC                            ;enter native mode
  320.                   XCE
  321.                   LDA   >TBCOLOR                 ;find current text/background color
  322.                   SEC                            ;return to native mode
  323.                   XCE
  324.                   AND   #%00001111               ;clear text color
  325.                   TAY                            ;prepare to stuff result into FAC
  326.                   LDA   #$00
  327.                   JSR   GIVAYF                   ;float A,Y into FAC
  328.                   LDX   VARPNT                   ;prepare to store result
  329.                   LDY   VARPNT+1
  330.                   JSR   MOVMF                    ;store result into variable
  331.                   RTS                            ;done!
  332. RDCAPS      CMP   #'C'                     ;want Caps Lock status?
  333.                   BNE   RDHCOL                   ;no, check for border color value
  334.                   JSR   CHKCOM                   ;yes, now look for comma separator
  335.                   JSR   PTRGET                   ;find/create return status variable
  336.                   CLC                            ;enter native mode
  337.                   XCE
  338.                   LDA   >KYMODREG                ;find current special key register
  339.                   SEC                            ;return to emulation mode
  340.                   XCE
  341.                   AND   #%00000100               ;mask out all bits but Caps Lock
  342.                   BEQ   NOCAPS                   ;if zero, Caps Lock was UP
  343. CAPS          LDY   #$01                     ;not zero, Caps Lock was DOWN
  344.                   BNE   STUFCAPS                 ; (forced branch always taken)
  345. NOCAPS      LDY   #$00                     ;return zero, Caps Lock was UP
  346. STUFCAPS  LDA   #$00                     ;prepare to float result into FAC
  347.                   JSR   GIVAYF                   ;float into FAC
  348.                   LDX   VARPNT                   ;prepare to store result
  349.                   LDY   VARPNT+1
  350.                   JSR   MOVMF                    ;store result
  351.                   RTS                            ;done!
  352. RDHCOL      CMP   #'H'                     ;want border color status?
  353.                   BNE   RDCTRL                   ;no, check for Control Key status
  354.                   JSR   CHKCOM                   ;yes, check for comma separator
  355.                   JSR   PTRGET                   ;find/create return status variable
  356.                   CLC                            ;enter native mode
  357.                   XCE
  358.                   LDA   >CLOCKCTL                ;find current border color
  359.                   SEC                            ;return to emulation mode
  360.                   XCE
  361.                   AND   #%00001111               ;clear all bits but border color
  362.                   TAY                            ;prepare to float result into FAC
  363.                   LDA   #$00
  364.                   JSR   GIVAYF                   ;float into FAC
  365.                   LDX   VARPNT                   ;prepare to store result
  366.                   LDY   VARPNT+1
  367.                   JSR   MOVMF                    ;store result
  368.                   RTS                            ;done!
  369. RDCTRL      CMP   #'K'                     ;want Control Key status?
  370.                   BNE   RDLANG                   ;no, check for Language
  371.                   JSR   CHKCOM                   ;yes, check for comma separator
  372.                   JSR   PTRGET                   ;find/create return status variable
  373.                   CLC                            ;enter native mode
  374.                   XCE
  375.                   LDA   >KYMODREG                ;find current special key register
  376.                   SEC                            ;return to emulation mode
  377.                   XCE
  378.                   AND   #%00000010               ;clear out all bits but Control Key
  379.                   BEQ   NOCTRL                   ;if zero, Ctrl Key is presently UP
  380. CTRL          LDY   #$01                     ;not zero, Ctrl Key is presently DOWN
  381.                   BNE   STUFCTRL                 ; (forced branch always taken)
  382. NOCTRL      LDY   #$00                     ;return zero, Ctrl Key was UP
  383. STUFCTRL  LDA   #$00                     ;prepare to float result into FAC
  384.                   JSR   GIVAYF                   ;float into FAC
  385.                   LDX   VARPNT                   ;prepare to store result
  386.                   LDY   VARPNT+1
  387.                   JSR   MOVMF                    ;store result
  388.                   RTS                            ;done!
  389. RDLANG      CMP   #'L'                     ;want current language?
  390.                   BNE   RDNKPD                   ;no check for Numeric Keypad keypress
  391.                   JSR   CHKCOM                   ;yes, check for comma separator
  392.                   JSR   PTRGET                   ;find/create return status variable
  393.                   CLC                            ;enter native mode
  394.                   XCE
  395.                   LDA   >LANGSEL                 ;find current language
  396.                   SEC                            ;return to emulation mode
  397.                   XCE
  398.                   AND   #%11100000               ;mask out NTSC/PAL and primary bits
  399.                   LSR   A                        ;move 3 bits to low nibble
  400.                   LSR   A                        ; (YYYxxxxx to xxxxxYYY, Y = language)
  401.                   LSR   A
  402.                   LSR   A
  403.                   LSR   A
  404.                   TAY                            ;prepare to float result into FAC
  405.                   LDA   #$00
  406.                   JSR   GIVAYF                   ;float into FAC
  407.                   LDX   VARPNT                   ;prepare to store result
  408.                   LDY   VARPNT+1
  409.                   JSR   MOVMF                    ;store result
  410.                   RTS                            ;done!
  411. RDNKPD      CMP   #'N'                     ;want Numeric Keypad keypress status
  412.                   BNE   RDSHFT                   ;no, check for Shift Key status
  413.                   JSR   CHKCOM                   ;yes, check for comma separator
  414.                   JSR   PTRGET                   ;find/create return status variable
  415.                   CLC                            ;enter native mode
  416.                   XCE
  417.                   LDA   >KYMODREG                ;find current special key register
  418.                   SEC                            ;return to emulation mode
  419.                   XCE
  420.                   AND   #%00010000               ;clear out all bits but Numeric Keypad
  421.                   BEQ   NONKPD                   ;if zero, no Numeric Keypad key pressed
  422. NKPD          LDY   #$01                     ;not zero, Numeric Keypad key pressed
  423.                   BNE   STUFNKPD                 ; (forced barnch always taken)
  424. NONKPD      LDY   #$00                     ;return zero, not a Numeric Keypad key
  425. STUFNKPD  LDA   #$00                     ;prepare to float result into FAC
  426.                   JSR   GIVAYF                   ;float into FAC
  427.                   LDX   VARPNT                   ;prepare to store result
  428.                   LDY   VARPNT+1
  429.                   JSR   MOVMF                    ;store result
  430.                   RTS                            ;done!
  431. RDSHFT      CMP   #'S'                     ;want Shift Key status?
  432.                   BNE   RDTEXT                   ;no, check for text color
  433.                   JSR   CHKCOM                   ;yes, check for comma separator
  434.                   JSR   PTRGET                   ;find/create return status variable
  435.                   CLC                            ;enter native mode
  436.                   XCE
  437.                   LDA   >KYMODREG                ;find current special key register
  438.                   SEC                            ;return to emulation mode
  439.                   XCE
  440.                   AND   #%00000001               ;clear out all bits but Shift key status
  441.                   BEQ   NOSHFT                   ;if zero, Shift Key is not being pressed
  442. SHFT          LDY   #$01                     ;not zero, Shift Key is being pressed
  443.                   BNE   STUFSHFT                 ; (forced branch always taken)
  444. NOSHFT      LDY   #$00                     ;return zero, Shift Key not pressed
  445. STUFSHFT  LDA   #$00                     ;prepare to float result into FAC
  446.                   JSR   GIVAYF                   ;float into FAC
  447.                   LDX   VARPNT                   ;prepare to store result
  448.                   LDY   VARPNT+1
  449.                   JSR   MOVMF                    ;store result
  450.                   RTS                            ;done!
  451. RDTEXT      CMP   #'T'                     ;want current text color?
  452.                   BNE   RDSPD                    ;no check for system speed
  453.                   JSR   CHKCOM                   ;yes, check for comma separator
  454.                   JSR   PTRGET                   ;find/create return status variable
  455.                   CLC                            ;enter native mode
  456.                   XCE
  457.                   LDA   >TBCOLOR                 ;find current text/background color
  458.                   SEC                            ;return to emulation mode
  459.                   XCE
  460.                   AND   #%11110000               ;mask out background color bits
  461.                   LSR   A                        ;move 4 bits to low nibble
  462.                   LSR   A                        ; (YYYYxxxx to xxxxYYYY, Y = color bits)
  463.                   LSR   A
  464.                   LSR   A
  465.                   TAY                            ;prepare to float result into FAC
  466.                   LDA   #$00
  467.                   JSR   GIVAYF                   ;float into FAC
  468.                   LDX   VARPNT                   ;prepare to store result
  469.                   LDY   VARPNT+1
  470.                   JSR   MOVMF                    ;store result
  471.                   RTS                            ;done!
  472. RDSPD        CMP   #'V'                     ;want current system speed?
  473.                   BEQ   V1                       ;yes
  474.                   LDX   #$35                     ;no, illegal quantity error
  475.                   JMP   ERROR
  476. V1              JSR   CHKCOM                   ;check for comma separator
  477.                   JSR   PTRGET                   ;find/create return status variable
  478.                   CLC                            ;enter native mode
  479.                   XCE
  480.                   LDA   >CYAREG                  ;find current system speed
  481.                   BPL   SLOW                     ;MSB low, speed set to SLOW
  482. FAST          LDY   #$01                     ;speed set to FAST
  483.                   BNE   DONE                     ; (forced branch always taken)
  484. SLOW          LDY   #$00                     ;speed set to SLOW
  485. DONE          SEC                            ;return to emulation mode
  486.                   XCE
  487.                   LDA   #$00                     ;prepare to float result into FAC
  488.                   JSR   GIVAYF                   ;float into FAC
  489.                   LDX   VARPNT                   ;prepare to store result
  490.                   LDY   VARPNT+1
  491.                   JSR   MOVMF                    ;store result
  492. END            RTS                            ;done!
  493.                   END
  494.